<!DOCTYPE html>
<html>
<head>
    <title>班级管理</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-4">
    <h2>班级管理</h2>
    
    <!-- 添加班级表单 -->
    <form method="post" class="mb-4">
        {% csrf_token %}
        <div class="input-group">
            <input type="text" name="class_name" placeholder="输入班级名称" required class="form-control">
            <button type="submit" name="add_class" class="btn btn-primary">添加班级</button>
        </div>
    </form>

    <!-- 班级列表 -->
    <table class="table table-striped">
        <thead>
            <tr>
                <th>班级名称</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for class in classes %}
            <tr>
                <td>{{ class.name }}</td>
                <td>
                    <form method="post" style="display:inline;">
                        {% csrf_token %}
                        <input type="hidden" name="delete_class" value="{{ class.id }}">
                        <button type="submit" class="btn btn-danger btn-sm">删除</button>
                    </form>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
</body>
</html>